package com.atguigu.e_remove;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;

public class Demo {
    public static void main(String[] args) {
        //创建List集合
        List<String> list = new ArrayList<>();
        System.out.println("list = " + list);//[]

        //添加元素 -> 依次添加
        list.add("张三丰");
        list.add("张翠山");
        list.add("张无忌");

        System.out.println("list = " + list);
        System.out.println("-------------------------");
        //列表迭代器对象 [列表迭代器对象只能服务List集合和其子类集合]
        Iterator<String> lit = list.iterator();

        list.set(0,"灭绝师太");

        while (lit.hasNext()) {
            //校验,获取,移动
            String name = lit.next();
            System.out.println("name = " + name);
        }

        System.out.println("list = " + list);
    }
}
